<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymleaf.org">
<meta charset="UTF-8">
<script src="../webapp/BootStrap/js/jquery.js"></script>
<script src="../webapp/BootStrap/js/bootstrap.js"></script>
<link rel="stylesheet" href="../webapp/BootStrap/css/bootstrap.css">
<head>
    <meta charset="UTF-8">
    <title>医院管理_科室</title>
    <script>


    </script>
    <style>

        #father{
            background-color: #f0f2f5;
            height: 1200px;
            width: 100%;
            float: right;
            border-width: 2px;
            border-color: #cccccc;
            border-style: solid;
        }
        #top{
            background-color: white;
            height: 7%;
            width: 100%;
            float: left;
        }
        #title{
            background-color: white;
            height: 3.5%;
            padding-top:0.5%;
            width: 100%;
            float: left;
            margin-top: 0.5%;
            font-size: 120%;
        }

        #find{
            background-color: white;
            height: 10%;
            width: 96%;
            float: left;
            margin: 2%;
            border-radius: 5px;
            padding: 1%;
        }
        #bedName{
            padding-left: 30%;
            padding-bottom: 1%;
            float: left;
            width: 70%;
            height: 40%;
            margin: 0 auto;
        }
        #bedName_left,#bedName_min,#bedName_right{
            float: left;
        }

        #input1{
            width: 400px;
            height: 36px;
            text-align: center;
            font-size: 110%;
        }
        #button1{
            width: 60px;
            height: 36px;
            font-size: 110%;
            background-color: cornflowerblue;
            color: #FFFFFF;
            border: 5px cornflowerblue solid;
            border-top-right-radius: 10px;
            border-bottom-right-radius: 10px;
            margin-top: 1.2%;
        }
        #choice{
            line-height: 0px;
            height: 35px;
            width: 100%;
            float: left;
            padding-bottom: 20px;
            margin-top: 1.2%;
        }
     #TheHospital,#TheShareholder,#dui{
		 width: 30%;
		 height: 35px;
		 float: left;
         margin-left: 0%;
         margin-right: 0%;
         margin-top: 1%;
	 }
	 #TheHospital{

	  }

        .sele1{
            height: 35px;
            width: 20%;
        }
        .sele2{
            height: 35px;
            width: 50%;
        }
		
        #shouyi{
            height: 35px;
            width: 25%;
            float: left;
        }
        #creatTime{
            padding-top: 10px;
            width: 51%;
            height: 37%;
            float: left;
            border: darkgray 1px solid;
			margin-left: 20%;
            margin-top: 1.5%;
			padding-left: 1%;
        }
        .text1{
            width: 30%;
            height: 24px;
        }
        #button2{
            width: 100px;
            height: 30px;
            font-size: 90%;
            background-color: gray;
            color: #FFFFFF;
            border: 5px gray solid;
            border-radius: 10px;
        }
        .layui-input{
            width: 255px;
            height: 24px;
			border-color: #A9A9A9;
			border-radius: 5px;
			border-style: solid;
			border-width: 1px;
        }
		
		#main{
		    background-color: white;
		    height:68%;
		    width: 96%;
		    float: left;
		    margin: 2%;
			margin-top: 0%;
		    border-radius: 5px;
		    padding: 2%;
		}
		
		.buttongrop1{
			width: 8%;
			height: 6%;
			font-size: 110%;
			background-color: #6495ED;
			color: white;
			border: 1px #6495ED solid;
			border-radius: 3px;
		}
		.buttongrop1:active {
			background-color: white;
			color: black;
			border: 1px lightgray solid;
		    }
		
		#count{
			font-size: 150%;
			width: 96%;
			height:8%;
			background-color: #e4f2ff;
			border: skyblue 2px solid;
			border-radius: 3px;
			margin-top: 2%;
			padding-top: 0.75%;
			padding-left: 4%;
		}
		
		#tableBox{
			font-size: 110%;
			width: 100%;
			height:80%;
			margin-top: 3%;
            text-align: left;
		}
		table{
			text-align: center;
			width: 100%;
			border-collapse: separate;
			border-spacing: 0px 12px;
            text-align: left;
		}
		th{
			padding-top: 1%;
			padding-bottom: 1%;
			background-color: #F0F2F5;
			padding-left: 0px;
			padding-right: 0px;
		}
		tr{
			margin-top: 10px;
			font-size: 120%;
		}
		td{
			border-bottom: lightgray solid 1px;
		}

        .buttongrop2{
            width: 40px;
            height: 40px;
            background-color: white;
            border-radius: 5px;
            border: #6495ED 1px solid;

        }
        .buttongrop{
            color: white;
            width: 75px;
            height: 40px;
            background-color:#6495ED;
            border-radius: 5px;
            border:white 0px solid;

        }

		.turnOff{
		width: 85%;
		height:60%;
		background-color: crimson;
		border: crimson solid 4px;
		border-radius: 6px;
		color: #F0F2F5;
		font-size: 105%;
		}

        .input3{
            width: 65%;
            text-align: center;
            float: right;
        }
        .sele3{
            width: 65%;
            text-align: center;
            float: right;
            text-align: center;
            text-align-last: center;
        }
        .time{
            height: 30px;
            width: 100%;
            text-align: center;
            float: left;
        }
        .shan{
            height: 80%;
            width: 80%;
            background-color: #9c9c9c;
            color: white;
            border-radius: 5px;
        }
    </style>
    <script>

        request();
        function newRequest(){
            $.ajax({
                url:"/hosp/find",
                type:"post",
                datatype:"json",
                success:function(data){
                    newShow(data);
                }
            })
        }
        function request(){
            $.ajax({
                url:"/hosp/find",
                type:"post",
                datatype:"json",
                success:function(data){
                    show(data);
                }
            })
        }

        function show(data){
        var html="";
        var dui1="";
        var dui2="";
            for(var i in data.keshi.list){
                var h =data.keshi.list[i];

                    html+="<tr>"+
                        "<td>"+h.departmentname+"</td>"+
                        "<td>"
                    for(var i2 in data.yiyuan){
                        var h2 =data.yiyuan[i2];
                       if( h2.hospitalinfoid==h.departmentHospitalinfoid){
                         html+=""+h2.hospitalinfoname+""
                           break;
                       }
                    }
                    html+="</td>"+
                        "<td>"
                for(var i2 in data.duijieren){
                    var d2 =data.duijieren[i2];
                    if(d2.userid==h.userid){
                        html+=""+d2.username+""
                        break;
                    }
                }
               html+="</td>"+
                    "<td>"
                for(var i2 in data.duijieren){
                    var d2 =data.duijieren[i2];
                    if(d2.userid==h.userid){
                        html+=""+d2.userphone+""
                        break;
                    }
                }
                html+="</td>"
                html+="<td>"+h.departmentphone+"</td>"+
                    "<td>"+h.departmentsharing+"</td>"+
                    "<td>"+h.departmentcreatetime+"</td>"+
                    "<td><input type='button' class='shan' onclick='del("+h.departmentid+")' value='删除'/></td>"
            }

            $("#tb").html(html);

            //总
            $("#countNum").text("查询到的科室数："+data.keshi.total);

            //维修
            var x="";
            for(var i in data.weixiu){
                var h =data.weixiu[i]
                x+="<option value='"+h.userid+"'>"+h.username+"</option>"
            }
            $("#mxiu").html(x);

            //选择医院
           var html1 ="<option value='0'>-所有医院-</option>";
           var yi="";
           for(var i in data.yiyuan){
               var h =data.yiyuan[i]
               html1+="<option value='"+h.hospitalinfoid+"'>"+h.hospitalinfoname+"</option>"
               yi+="<option value='"+h.hospitalinfoid+"'>"+h.hospitalinfoname+"</option>"
           }
            $("#Hopsital").html(html1);
            $("#myi").html(yi);

            //选择对接人
            var html4 ="<option value='0'>-所有对接人-</option>";
            var dui="";
            for(var i in data.duijieren) {
                var d = data.duijieren[i];
                html4 += "<option value='" + d.userid + "'>" + d.username + "</option>"
                dui+="<option value='" + d.userid + "'>" + d.username + "</option>"
            }
                $("#duijie").html(html4);
            $("#mdui").html(dui);

            //选择股东
            var html2 ="<option value='0'>-所有股东-</option>";
            var gu="";
            var temp=[];
            var num=0;
            for(var i in data.gudong){
                var g =data.gudong[i];
                html2+="<option value='"+g.userid+"'>"+g.username+"</option>"
                gu+="<option value='"+g.userid+"'>"+g.username+"</option>"

            }
            $("#shareholder").html(html2);
            $("#mgu").html(gu);

            for(var i in data.yiji) {
                var f =data.yiji[i];
                dui1 += "<option value='" +f.userid+ "'>" + f.username + "</option>"
            }
            $("#myiji").html(dui1);
            for(var i in data.erji) {
                var f = data.erji[i];
                dui2 += "<option value='" + f.userid + "'>" + f.username + "</option>"
            }

            $("#merji").html(dui2);
            //分页
            var html3="";
            html3+= "<button type='button' class='buttongrop' onclick='ye("+data.keshi.navigateFirstPage+")'>首页</button>"

            for(var i in data.keshi.navigatepageNums){
                html3+="<button type='button' class='buttongrop2' onclick='ye("+data.keshi.navigatepageNums[i]+")'>"+data.keshi.navigatepageNums[i]+"</button>"
            }
            html3+="<button type='button' class='buttongrop' onclick='ye("+data.keshi.navigateLastPage+")'>尾页</button>"

            $("#fenye").html(html3);
        }

        function newShow(data) {
            var html="";
            var dui1="";
            var dui2="";
            for(var i in data.keshi.list){
                var h =data.keshi.list[i];

                html+="<tr>"+
                    "<td>"+h.departmentname+"</td>"+
                    "<td>"
                for(var i2 in data.yiyuan){
                    var h2 =data.yiyuan[i2];
                    if( h2.hospitalinfoid==h.departmentHospitalinfoid){
                        html+=""+h2.hospitalinfoname+""
                        break;
                    }
                }
                html+="</td>"+
                    "<td>"
                for(var i2 in data.duijieren){
                    var d2 =data.duijieren[i2];
                    if(d2.userid==h.userid){
                        html+=""+d2.username+""
                        break;
                    }
                }
                html+="</td>"+
                    "<td>"
                for(var i2 in data.duijieren){
                    var d2 =data.duijieren[i2];
                    if(d2.userid==h.userid){
                        html+=""+d2.userphone+""
                        break;
                    }
                }
                html+="</td>"
                html+="<td>"+h.departmentphone+"</td>"+
                    "<td>"+h.departmentsharing+"</td>"+
                    "<td>"+h.departmentcreatetime+"</td>"+
                    "<td><input type='button' class='shan' onclick='del("+h.departmentid+")' value='删除'/></td>"
            }

            $("#tb").html(html);

            //总
            $("#countNum").text("查询到的科室数："+data.keshi.total);

            //分页
            var html3="";
            html3+= "<button type='button' class='buttongrop' onclick='ye("+data.keshi.navigateFirstPage+")'>首页</button>"

            for(var i in data.keshi.navigatepageNums){
                html3+="<button type='button' class='buttongrop2' onclick='ye("+data.keshi.navigatepageNums[i]+")'>"+data.keshi.navigatepageNums[i]+"</button>"
            }
            html3+="<button type='button' class='buttongrop' onclick='ye("+data.keshi.navigateLastPage+")'>尾页</button>"

            $("#fenye").html(html3);
        }

        function find(){
            var duijie = $("#duijie").val();
            var hopsital =$("#Hopsital").val();
            var gu= $("#shareholder").val();
            $.ajax({
                url:"/hosp/find",
                type:"post",
                datatype:"json",
                data:{"userid":duijie,"departmentHospitalinfoid":hopsital,"usershareholderid":gu},
                success:function(data){
                    newShow(data);
                }
            })
        }
        function pm(num){
            var duijie = $("#duijie").val();
            var hopsital =$("#Hopsital").val();
            var gu= $("#shareholder").val();
            var pageNum=num;
            $.ajax({
                url:"/hosp/find",
                type:"post",
                datatype:"json",
                data:{"userid":duijie,"hospitalinfoid":hopsital,"usershareholderid":gu,"pageNum":num},
                success:function(data){
                    newShow(data);
                }
            })
        }
        function ye(num){
            pm(num);
        }

        function del(id){
            $.ajax({
                url:"/hosp/delete",
                type:"post",
                datatype:"json",
                data:{"departmentid":id},
                success:function(data){
                   if(data){
                    newRequest();
                   }else{
                   alert("删除成功");
                   }
                }
            })
        }

    </script>
</head>

<body>
<div id="father">
    <div id="top">

    </div>

    <div id="title">
        &nbsp;&nbsp;<span style="color: #CCCCCC; ">医院管理/</span>科室
    </div>

    <div id="find">
        <div id="choice">
            <div id="TheHospital">
                 选择医院
				   <select id="Hopsital" class="sele2">
				       <option>-所有医院-</option>
				   </select>
            </div>
            <div id="dui">
                选择对接人
                <select id="duijie" class="sele2">
                    <option>-所有对接人-</option>
                </select>
            </div>
            <div id="TheShareholder">
                选择股东
				<select id="shareholder" class="sele2">
                    <option>-所有人员-</option>
                </select>
            </div>
            <input type="button" id="button1" onclick="find()" value="查询"/>
     </div>

<!--        <div id="creatTime">-->
<!--            <div style="float: left">创建时间</div>-->
<!--            <div style="float: left;margin-left: 3%"><input type="text" class="layui-input time" id="test31" placeholder="开始时间"></div>-->
<!--            <div style="float: left;margin-left: 3%">至</div>-->
<!--            <div style="float: left;margin-left: 2.5%"><input type="text" class="layui-input time" id="test32" placeholder="结束时间"></div>-->
<!--            <div style="float: left;margin-left: 6%"><input  type="button" id="button2" value="清空"></div>-->
<!--        </div>-->
		
    </div>
	
	<div id="main">
        <button type="button" class="buttongrop1" data-toggle="modal" data-target="#myModal">
            新增科室
        </button>
		
		<div id="count">
            <div id="countNum" style="margin-right: 10% ;float: left">总科室数:20000</div>
            <div id="fenye" style="float: left">
                <input type="button"class="buttongrop" value="首页"/>
                <input type="button"class="buttongrop2" value="1"/>
                <input type="button"class="buttongrop2" value="2"/>
                <input type="button"class="buttongrop2" value="3"/>
                <input type="button"class="buttongrop2" value="4"/>
                <input type="button" class="buttongrop" value="尾页"/>
            </div>
		</div>
		
		<div id="tableBox">
			
			<table>
				<thead>
					<tr>

						<th>科室名称</th>
						<th>所属医院</th>
						<th>科室对接人</th>
						<th>对接人电话</th>
						<th>科室电话</th>
						<th>收益分成(%)</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="tb">
					<tr>
						<td>外科</td>
						<td>赫特医院</td>
						<td>赫特</td>
						<td>152456123456</td>
						<td>12562512334556</td>
						<td>30</td>
						<td>2018-10-12 12:20:00</td>
						<td><input type="button" value="删除" class="shan"/> </td>
					</tr>
				
				</tbody>
				
			</table>
			
		</div>
		
	</div>
	
</div>
<div class="modal fade" id="myModal">
    <div class="modal-dialog">
        <div class="modal-content">

            <!-- 模态框头部 -->
            <div class="modal-header" style="background-color: black; color: white;">
                <h4 class="modal-title">新增科室</h4>
                <button type="button" class="close" data-dismiss="modal" style="color: white;">&times;</button>
            </div>

            <!-- 模态框主体 -->
            <div class="modal-body" style="padding-right: 58px;">
                <div style="padding-left: 16px;">
                    选择医院
                    <select class="sele3" id="myi">
                        <option>-选择医院-</option>
                    </select>

                </div>
                <br/>
                <div style="padding-left: 16px;">
                    科室名称：
                    <input type="text" placeholder="请输入科室名称" id="mke"  class="input3"/>
                </div>
                <br/>
                <div style="padding-left: 16px;">
                    科室电话：
                    <input type="text" placeholder="请输入科室名称" id="mdian"  class="input3"/>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    科室对接人：
                    <select class="sele3" id="mdui">
                        <option>-选择科室对接人-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                维修人员：
                <select class="sele3" id="mxiu">
                    <option>-选择维修人员-</option>
                </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    收益分成(%)
                    <select id="mfen" class="sele3">
                        <option value="5">5</option>
                        <option value="10">10</option>
                        <option value="15">15</option>
                        <option value="20">20</option>
                        <option value="25">25</option>
                        <option value="30">30</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    股东：
                    <select class="sele3" id="mgu">
                        <option>-请选择股东-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    一级分销商：
                    <select class="sele3" id="myiji">
                        <option>-请选择分销商-</option>
                    </select>
                </div>
                <br/>
                <div  style="padding-left: 16px;">
                    二级分销商：
                    <select class="sele3" id="merji">
                        <option>-请选择分销商-</option>
                    </select>
                </div>

            </div>

            <!-- 模态框底部 -->
            <div class="modal-footer">
                <button type="button" class="btn btn-primary"  data-dismiss="modal" onclick="add()">提交</button>
                <button type="button" class="btn btn-secondary"  data-dismiss="modal">关闭</button>
            </div>

        </div>
    </div>
</div>

</body>
</html>
<script>
    function add(){
        var departmentHospitalinfoid =$("#myi").val();
        var departmentname =$("#mke").val();
        var userid=$("#mdui").val();
        var departmentsharing=$("#mfen").val();
        var usershareholderid=$("#mgu").val();
        var userdistributorsid1=$("#myiji").val();
        var userdistributorsid2=$("#merji").val();

        var useraccendantid= $("#mxiu").val();
        var departmentphone =$("#mdian").val();

        $.ajax({
            url:"/hosp/insert",
            type:"post",
            datatype:"json",
            data:{"departmentHospitalinfoid":departmentHospitalinfoid,"departmentname":departmentname,"userid":userid,
                "departmentsharing":departmentsharing,"usershareholderid":usershareholderid,"userdistributorsid1":userdistributorsid1,
                "userdistributorsid2":userdistributorsid2,"departmentphone":departmentphone,"useraccendantid":useraccendantid},
            success:function(data){
                if(data){
                    newRequest();
                }else{
                    alert("提交失败");
                }
            }
        })

    }
</script>
